<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>

<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

<!-- jsx转为js -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>

<!-- 自 React v15.5 起，React.PropTypes 已移入另一个包中。请使用 prop-types 库代替 -->
<script src="https://unpkg.com/prop-types@15.6/prop-types.js"></script>

<script type="text/babel">
    //props 是只读的，不能修改
    class Person extends React.Component {
        // 对标签属性进行类型限制
        static propTypes = {
            name: PropTypes.string,
            // abc: PropTypes.func // 函数
        }

        // 指定默认标签属性
        static defaultProps = {
            sex: "不男不女"
        }

        constructor(props) {
            // 构造器接收props，取决于是否希望在构造器中通过访问props
            super(props)
            console.log(props)
        }

        render() {
            let {name, age, sex} = this.props
            return (
                    <ul>
                        <li>姓名：{this.props.name}</li>
                        <li>性别：{this.props.sex}</li>
                        <li>年龄：{age + 1}</li>
                    </ul>
            )
        }
    }

    ReactDOM.render(<Person name="tom1" age={18} sex="女"/>, document.getElementById("test1"))
</script>
</body>
</html>